import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import { BundleManager } from 'db://assets/Scripts/Framework/Managers/BundleManager';
import { WeaponUI } from './WeaponUI';
import { MainUI } from './MainUI';
const { ccclass, property } = _decorator;

@ccclass('WeaponTypeUI')
export class WeaponTypeUI extends Component {

    @property(Label)
    nameLabel: Label;

    @property(Sprite)
    weaponSprite: Sprite;

    @property(Node)
    choose: Node;

    start() {

    }

    update(deltaTime: number) {

    }

    _Init(data: any) {
        this.choose.active = false;
        this.nameLabel.string = data.name;
        BundleManager.GetBundle("MainPack").load(data.spriteFrame, SpriteFrame, (err, data) => { this.weaponSprite.spriteFrame = data });
    }

    Click() {
        WeaponUI.Instance._SwitchWeapon(this.node);
        MainUI.Instance.PlayClick();
    }

}


